package com.vilicode.excel;


import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

public class UserGroupConverter implements Converter<UserGroup> {

    @Override
    public Class<UserGroup> supportJavaTypeKey() {
        return UserGroup.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return null;
    }

    @Override
    public CellData convertToExcelData(UserGroup value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
        if (value == null) {
            return new CellData("");
        }
        return new CellData(value.getName());
    }

    @Override
    public UserGroup convertToJavaData(CellData cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
        UserGroup userGroup = new UserGroup();
        userGroup.setName(cellData.getStringValue());
        return userGroup;
    }
}
